/**
 * @description: 1
 * @return {type}
 */
/* console.log(1);

setTimeout(() => {
    Promise.resolve().then(() => {
        console.log(2);
    });
}, 0);

console.log(3);

new Promise((resolve) => {
    for (let i = 0; i <= 100; i++) {
        if (i === 100) {
            resolve();
        }
    }
}).then(() => {
    console.log(4);
}).then(() => {
    console.log(5);
});

console.log(6); */
/**
 * @description: 2
 * @return {type}
 */
/* setTimeout(() => {
    console.log("timeout");
}, 0)

const promise = new Promise(res => {
    console.log("promise")
    res("promise resolve")
});

(async () => {
    console.log("async start");
    const str = await promise;
    console.log(str);
})()
promise.then(() => {
    console.log("log-promise1-then");
})
console.log("log-end"); */
/**
 * @description: 3
 * @param {type} function
 * @return {type}
 */
/* setTimeout(function () {
    console.log("setTimeout1");
    new Promise(function (resolve) {
        resolve('');
    }).then(function () {
        new Promise((resolve) => {
            resolve('')
        }).then(function () {
            console.log("then4");
        })
        console.log("then2");
    })
})

new Promise(function (resolve) {
    console.log("promise1");
    resolve("")
}).then(function () {
    console.log("then1");
})

setTimeout(() => {
    console.log("settimeout2");
});
console.log(2);
queueMicrotask(() => {
    console.log("queueMicrotask1");
})
new Promise(function (resolve) {
    resolve('')
}).then(function () {
    console.log("then3");
}) */

/**
 * @description: 4
 * @return {type}
 */
/* async function async1(params) {
    console.log("async start");
    await async2();
    console.log("async1 end");
}
async function async2(params) {
    console.log("async2");
}
console.log("scriot start");
setTimeout(function () {
    console.log("setTimeout");
}, 0);
async1();
new Promise(function (resolve) {
    console.log("promise1");
    resolve();
}).then(function () {
    console.log("promise2");
});
console.log("script end"); */
/**
 * @description: 5
 * @return {type}
 */
/* Promise.resolve().then(() => {
    console.log(0);
    return Promise.resolve(4)
}).then(res => {
    console.log(res)
})
Promise.resolve()
    .then(() => {
        console.log(1);
    }).then(() => {
        console.log(2)
    }).then(() => {
        console.log(3)
    }).then(() => {
        console.log(5)
    }).then(() => {
        console.log(6)
    }) */
